package com.tobeface.wechat.message.builder;

import com.google.common.collect.Maps;
import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.message.WeChatMessageBuilder;
import com.tobeface.wechat.message.WeChatMessagePayloads;
import com.tobeface.wechat.message.WeChatMessageTypes;

import java.util.Map;

/**
 * @author loudyn
 */
public class VideoTypedMessageBuilder extends AbstractTypedMessageBuilder {

    private String mediaId;
    private String title;
    private String descr;

    /**
     * @param parent
     */
    public VideoTypedMessageBuilder(WeChatMessageBuilder parent) {
        super(parent);
    }

    /**
     * @param mediaId
     * @return
     */
    public VideoTypedMessageBuilder mediaId(String mediaId) {
        Requires.hasText(mediaId, "mediaId must not be null or emtpy!");
        this.mediaId = mediaId;
        return this;
    }

    /**
     * @param title
     * @return
     */
    public VideoTypedMessageBuilder title(String title) {
        Requires.hasText(title, "title must not be null or emtpy!");
        this.title = title;
        return this;
    }

    /**
     * @param descr
     * @return
     */
    public VideoTypedMessageBuilder descr(String descr) {
        Requires.hasText(descr, "descr must not be null or emtpy!");
        this.descr = descr;
        return this;
    }

    @Override
    protected void configPayloads(Map<String, Object> payloads) {
        Map<String, String> payload = Maps.newHashMap();
        payload.put(WeChatMessagePayloads.MEDIAID_PAYLOAD, mediaId);
        payload.put(WeChatMessagePayloads.TITLE_PAYLOAD, title);
        payload.put(WeChatMessagePayloads.DESCR_PAYLOAD, descr);
        payloads.put("Video", payload);
        payloads.put(WeChatMessagePayloads.MSGTYPE_PAYLOAD, WeChatMessageTypes.VIDEO);
    }
}
